/**
 * @author LKQ
 * @date 2022/1/14 10:00
 * @description O(n^2)
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {1, 2, 3, 4};
        solution.productExceptSelf(nums);
    }
    public int[] productExceptSelf(int[] nums) {
        int n = nums.length;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            ans[i] = 1;
        }
        for (int i = 0; i < n; i++) {
            int j = 0;
            while (j < n) {
                if (j != i) {
                    ans[j] *= nums[i];
                }
                j++;
            }
        }
        return ans;
    }
}
